//
//  GTChoicenessViewController.m
//  GiftTalk
//
//  Created by Wan on 16/3/23.
//  Copyright © 2016年 Wan. All rights reserved.
//

#import "GTChoicenessViewController.h"
#import "GTChoicenessHeaderView.h"


@interface GTChoicenessViewController ()

/** 头控件 */
//@property (weak, nonatomic) GTChoicenessHeaderView *choicenessHeaderView;

@end

@implementation GTChoicenessViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 1. 添加头部视图
    [self setupTableHeaderView];
    
    // 2. 调整 tableView 间距
    [self setupTableViewContentInsets];
}

/**
 *  首页头部视图
 */
- (void)setupTableHeaderView
{
    // 直接添加到 tableView 的 header 会有问题，需要有一个容器
    GTChoicenessHeaderView *headerView = [GTChoicenessHeaderView header];
    UIView *containerView = [[UIView alloc] initWithFrame:headerView.frame];
    containerView.height += GTTableViewGroupMargin;
    [containerView addSubview:headerView];
    
    self.tableView.tableHeaderView = containerView;
}

/**
 *  调整 tableView 间距
 */
- (void)setupTableViewContentInsets
{
    UIEdgeInsets insets = self.tableView.contentInset;
    insets.top = 5;
    
    self.tableView.contentInset = insets;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
